import { Exclude } from 'class-transformer';
import {
  Column,
  CreateDateColumn,
  Entity,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';

@Entity('category', { schema: 'shop' })
export class Category {
  constructor(partial: Partial<Category>) {
    Object.assign(this, partial);
  }

  @PrimaryGeneratedColumn()
  id: number;

  @Column({ length: 20 })
  title: string;

  @Column({ length: 100 })
  remark: string;

  @Column()
  icon: string;

  @Column({ type: 'tinyint', default: 0 })
  order: number;

  @Column({ name: 'is_delete', type: 'tinyint', default: 1, select: false })
  @Exclude()
  isDelete: number;

  @CreateDateColumn({ name: 'create_time' })
  createTime: Date;

  @UpdateDateColumn({ name: 'modify_time' })
  modifyTime: Date;
}
